package com.routz.bitblog.blog.blog.service.imp;

import com.routz.bitblog.blog.blog.entity.Article;
import com.routz.bitblog.blog.blog.mapper.ArticleMapper;
import com.routz.bitblog.blog.blog.service.BlogService;
import com.routz.bitblog.blog.edit.service.EditService;
import com.routz.bitblog.blog.storge.service.StorgeService;
import org.springframework.beans.factory.annotation.Autowired;

public class BlogServiceImp implements BlogService {

    private EditService editService;
    private StorgeService storgeService;
    private ArticleMapper articleMapper;

    @Autowired
    public BlogServiceImp(EditService editService, StorgeService storgeService, ArticleMapper articleMapper) {
        this.editService = editService;
        this.storgeService = storgeService;
        this.articleMapper = articleMapper;
    }

    @Override
    public void save(Article article) {
        // 保存或修改
        // 调用编辑
        editService.edit(article.getContent());
        // 调用保存
        storgeService.storge(article.getContent());
        // 存入数据库
        articleMapper.insert(article);
    }

    @Override
    public void publish(Article article) {
        // 调用编辑
        editService.edit(article.getContent());
        // 调用保存
        storgeService.storge(article.getContent());
        // 存入数据库
        articleMapper.insert(article);
    }

    @Override
    public void del(String articleId) {

    }

    @Override
    public void update(Article article) {

    }

    @Override
    public Article findOne(String articleId) {
        return null;
    }
}
